#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   App_ReadDTCInfomation_0x19_test.py
@Time    :   2024/09/02 13:31:28
@Author  :   YangLiANG 
@Version :   1.0
@Contact :   yangliang@chengtech.com
@License :   (C)Copyright 2022-2025
@Desc    :   None
'''

# here put the import lib
from pytest_assume.plugin import assume

import pytest
import time
import Set_up
from sympy import I
# from sympy import assuming
from commDriver.TS_CAN import *
import allure
import sys
from collections.abc import Iterable
from commDriver.modbus_plc import *

from sqlalchemy import false
sys.dont_write_bytecode = True

NoFault_DTCByte_list = [
    ([0x19, 0x04, 0x98, 0x7A, 0x17, 0x1], [0x59, 0x04, 0x98, 0x7A, 0x17, 0x00]),
    ([0x19, 0x04, 0x98, 0x7A, 0x16, 0x1], [0x59, 0x04, 0x98, 0x7A, 0x16, 0x00]),
    ([0x19, 0x04, 0x98, 0x8C, 0x98, 0x1], [0x59, 0x04, 0x98, 0x8C, 0x98, 0x00]),
    ([0x19, 0x04, 0xF2, 0x4C, 0x88, 0x1], [0x59, 0x04, 0xF2, 0x4C, 0x88, 0x00]),
    ([0x19, 0x04, 0xF2, 0x4F, 0x88, 0x1], [0x59, 0x04, 0xF2, 0x4F, 0x88, 0x00]),
    # ([0x19,0x04,0x98,0x96,0x78,0x1],[0x59,0x04,0x98,0x96,0x78,0x00]),
    # ([0x19,0x04,0x98,0x7C,0x54,0x1],[0x59,0x04,0x98,0x7C,0x54,0x00]),
    ([0x19, 0x04, 0x98, 0x99, 0xFF, 0x1], [0x59, 0x04, 0x98, 0x99, 0xFF, 0x00]),
    ([0x19, 0x04, 0x98, 0x8C, 0x00, 0x1], [0x59, 0x04, 0x98, 0x8C, 0x00, 0x00]),
    ([0x19, 0x04, 0x98, 0x8C, 0x78, 0x1], [0x59, 0x04, 0x98, 0x8C, 0x78, 0x00]),
    ([0x19, 0x04, 0x98, 0x8C, 0x96, 0x1], [0x59, 0x04, 0x98, 0x8C, 0x96, 0x00]),
    ([0x19, 0x04, 0xF2, 0x48, 0x87, 0x1], [0x59, 0x04, 0xF2, 0x48, 0x87, 0x00]),
    ([0x19, 0x04, 0xF2, 0x40, 0x87, 0x1], [0x59, 0x04, 0xF2, 0x40, 0x87, 0x00]),
    ([0x19, 0x04, 0xD7, 0x6F, 0x87, 0x1], [0x59, 0x04, 0xD7, 0x6F, 0x87, 0x00]),
    ([0x19, 0x04, 0xD7, 0x64, 0x87, 0x1], [0x59, 0x04, 0xD7, 0x64, 0x87, 0x00]),
    ([0x19, 0x04, 0xF2, 0x48, 0x87, 0x1], [0x59, 0x04, 0xF2, 0x48, 0x87, 0x00]),
    ([0x19, 0x04, 0xD7, 0x6A, 0x87, 0x1], [0x59, 0x04, 0xD7, 0x6A, 0x87, 0x00]),
    ([0x19, 0x04, 0xD7, 0x70, 0x87, 0x1], [0x7F, 0x19, 0x31]),
    ([0x19, 0x04, 0xD7, 0x71, 0x87, 0x1], [0x7F, 0x19, 0x31]),
    ([0x19, 0x04, 0xD7, 0x72, 0x87, 0x1], [0x7F, 0x19, 0x31])]

St_EngineRunning = Set_up.NetName, Set_up.nodeName, 'VCU_PDCU_0x230', 'VCU_STRATEGY_SHIFT_POSITION'


class Test_ReadDTCInfomation_phy(object):

    def setSignalValue(self, Driver, signal_list, value):
        Driver['CAN'].write_db_signal(signal_list[0], signal_list[1], signal_list[2], signal_list[3], value)
        time.sleep(0.2)
        readValue = Driver['CAN'].read_db_signal(signal_list[0], signal_list[1], signal_list[2], signal_list[3])


    ids = ["Request {0}".format(binascii.b2a_hex(bytearray(req), ' '))for req, resp in NoFault_DTCByte_list]
    '''NO Fault'''
    ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
    @allure.severity('normal')
    @allure.story('Test read dtc information service 0x19')
    @allure.description('Test reportDTCByStatusMask of 0x19 in default session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/62a69d6cb35db4f20e37703a/cases')
    @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
    def test_DTCSnapshotRecordNUM_No_Fault_Default_Phy(self, action, Driver, dtcNumber,dtcName):
        iStep = 1
        req =  [0x19,0x04] + dtcNumber + [0x01]

        if dtcNumber == [0x98,0x7C,0x54] or dtcNumber == [0xAC,0xD2,0x78] or dtcNumber == [0xAC,0xE6,0x55]:
            resp = [0x59,0x04] + dtcNumber
        else:
            resp = [0x59,0x04] + dtcNumber + [0x00]
        logging.info(f"Test [{dtcName}:{dtcNumber}] by SID_0x19-Subfunction_0x04-DTCExtendedDataRecordNumb_01")
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDS', 'ClearFault')

    ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]
    @allure.severity('normal')
    @allure.story('Test read dtc information service 0x19')
    @allure.description('Test reportDTCByStatusMask of 0x19 in extended session with physical addressing')
    @allure.testcase('Test cases address:https://chengtech.pingcode.com/testhub/libraries/62a69d6cb35db4f20e37703a/cases')
    @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
    def test_DTCSnapshotRecordNUM_No_Fault_extended_Phy(self, action, Driver, dtcNumber,dtcName):
        iStep = 1
        req =  [0x19,0x04] + dtcNumber + [0x01]
        if dtcNumber == [0x98,0x7C,0x54] or dtcNumber == [0xAC,0xD2,0x78] or dtcNumber == [0xAC,0xE6,0x55]:
            resp = [0x59,0x04] + dtcNumber
        else:
            resp = [0x59,0x04] + dtcNumber + [0x00]
        logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x04-DTCExtendedDataRecordNumb_01")
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDS', 'ClearFault')


    @pytest.mark.smoke
    @allure.severity('normal')
    @allure.description('Test abnormal voltage DTCSnapshot Record By DTCNumber in default session with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/6306e0482ce6d84a055b6e90/cases')
    def test_abnormal_voltage_DTCSnapshotRecordByDTCNumber_Default_Phy1(self, action, Driver, default_session):
        iStep = 1    
        Driver['CAN'].set_signal_IGN(2)
        self.setSignalValue(Driver, St_EngineRunning, 0)
        time.sleep(2)
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x14, 0xFF, 0xFF, 0xFF], [0x54], 1, iStep, False, 'UDS', 'noClearFault')

        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04, 0xF2, 0x48, 0x87, 0x01], [0x59, 0x04, 0xF2, 0x48, 0x87, 0x00], 0, iStep, False, 'UDS', 'noClearFault')
        
        # 设置点火信号
          # run 0x02
        # 设置车速
        Driver['CAN'].set_signal_Speed(1.0125)  # 0x12  (2.025)
        # 设置年
        Driver['CAN'].set_signal_Year(2022)  # 0x16
        # 设置月
        Driver['CAN'].set_signal_Month(9)  # 0x09
        # 设置日
        Driver['CAN'].set_signal_Day(16)   # 0x10
        # 设置时
        Driver['CAN'].set_signal_Hour(10)  # 0x0A
        # 设置分
        Driver['CAN'].set_signal_Minute(11)  # 0x0B
        # 设置秒
        Driver['CAN'].set_signal_Second(12)   # 0x0C
        Driver['CAN'].set_signal_Gear(2)
        time.sleep(3)
        with allure.step(f"Step{iStep}:Set:0x1B1信号丢失"):
            Driver['CAN'].set_0x1B1_lost_error(True)
            time.sleep(1.5)
            iStep += 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04, 0xF2, 0x48, 0x87, 0x01], [0x59, 0x04, 0xF2, 0x48, 0x87, 0x09, 0x01], 0, iStep, False, 'UDS', 'noClearFault')
        P = uds_resp[7:34]

        with allure.step(f"Step{iStep}:Set:0x1B1信号恢复"):
            Driver['CAN'].set_0x1B1_lost_error(False)
            time.sleep(1)
            iStep += 1
        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04, 0xF2, 0x48, 0x87, 0x01], [0x59, 0x04, 0xF2, 0x48, 0x87, 0x08, 0x01], 0, iStep, False, 'UDS', 'noClearFault')
        # 判断车速 1261
        if uds_resp[8:12] != [0x12, 0x61, 0x00, 0x12]:
            actuRespStr = binascii.b2a_hex(bytearray(uds_resp[8:12]), ' ')
            logging.error(f'correct vspeed:[0x12,0x61,0x00,0x12], actual response:[{actuRespStr}]')
        with assume:assert uds_resp[8:12] == [0x12, 0x61,0x00, 0x12]

        # 判断年月日时分秒 1270
        if uds_resp[12:20] != [0x12, 0x70, 0x22, 0x09, 0x16, 0x10, 0x11, 0x12]:
            actuRespStr = binascii.b2a_hex(bytearray(uds_resp[12:20]), ' ')
            logging.error(f'correct vspeed:[0x12,0x70,0x22,0x09], actual response:[{actuRespStr}]')
        with assume:assert uds_resp[12:20] == [0x12, 0x70, 0x22, 0x09, 0x16, 0x10, 0x11, 0x12]

        vltage = (uds_resp[22] << 8 | uds_resp[23])*0.01
        with assume: assert 11.5 <= vltage <= 12.1, logging.error(f'correct vltage:[11.8 <= vltage <= 12.1], actual response:[{vltage}]')
        if uds_resp[24:32] != [0x12, 0x62, 0x02, 0x12, 0x63, 0x03, 0x12, 0x64]:
            actuRespStr = binascii.b2a_hex(bytearray(uds_resp[24:32]), ' ')
            logging.error(f'correct vltage:[0x12,0x62,0x02,0x12,0x63,0x03,0x12,0x64], actual response:[{actuRespStr}]')
        with assume:assert uds_resp[24:32] == [0x12, 0x62,0x02, 0x12, 0x63, 0x03, 0x12, 0x64]
        
        temperature = (uds_resp[32] << 8 | uds_resp[33])*0.01-40.0
        if -40 > temperature or temperature > 150:
            logging.error(f'correct temperature:[-40 <= temperature <= 150], actual response:[{temperature}]')
        with assume:assert -40 <= temperature <= 150
        if uds_resp[7:] != P:
            actuRespStr = binascii.b2a_hex(bytearray(uds_resp[7:]), ' ')
            correct_response = binascii.b2a_hex(bytearray(P), ' ')
            logging.error(f'correct response:[{correct_response}], actual response:[{actuRespStr}]')
        with assume:assert uds_resp[7:] == P

        iStep = Driver['CAN'].SetVolt(Driver, 18, 3, iStep)
        iStep = Driver['CAN'].SetVolt(Driver, 12, 2, iStep)

        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04, 0xF2, 0x48, 0x87, 0x01], [0x59, 0x04, 0xF2, 0x48, 0x87, 0x08, 0x01], 0, iStep, False, 'UDS', 'noClearFault')
        
        if uds_resp[7:] != P:
            actuRespStr = binascii.b2a_hex(bytearray(uds_resp[7:]), ' ')
            correct_response = binascii.b2a_hex(bytearray(P), ' ')
            logging.error(f'correct response:[{correct_response}], actual response:[{actuRespStr}]')
            with assume:assert P == uds_resp[7:]

        iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x14, 0xFF, 0xFF, 0xFF], [0x54], 0, iStep, False, 'UDS', 'ClearFault')

        Driver['CAN'].set_signal_IGN(2)   # ACC 0x01
        # 设置车速
        Driver['CAN'].set_signal_Speed(0)  # 0x12
        # 设置年
        Driver['CAN'].set_signal_Year(2000)  # 0x16
        # 设置月
        Driver['CAN'].set_signal_Month(0)  # 0x09
        # 设置日
        Driver['CAN'].set_signal_Day(0)   # 0x10
        # 设置时
        Driver['CAN'].set_signal_Hour(0)  # 0x0A
        # 设置分
        Driver['CAN'].set_signal_Minute(0)  # 0x0B
        # 设置秒
        Driver['CAN'].set_signal_Second(0)   # 0x0C
        Driver['CAN'].set_signal_Gear(1)
        self.setSignalValue(Driver, St_EngineRunning, 0)

    def SnapShot01(self, Driver, iStep):
        DTCNumber_V_H = Set_up.DTC_list_all['DTC_VBAT_HIGH']
        DTCNumber_V_L = Set_up.DTC_list_all['DTC_VBAT_LOW']
        # 生成故障
        Driver['CAN'].SetVolt(Driver, 17.5, 1.5, iStep)

        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04]+DTCNumber_V_H+[0x01], [0x59, 0x04]+DTCNumber_V_H+[0x09, 0x01], 0, iStep, False, 'UDS', 'noClearFault')
        snapshot_01 = uds_resp[7:]
        iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

        # 设置车速>3kph
        Driver['CAN'].set_signal_Speed(80)
        time.sleep(0.5)

        # 再次生成故障
        Driver['CAN'].SetVolt(Driver, 17.5, 1.5, iStep)
        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04]+DTCNumber_V_H+[0x01], [0x59, 0x04]+DTCNumber_V_H+[0x09, 0x01], 0, iStep, False, 'UDS', 'noClearFault')

        with allure.step(f"Step{iStep}: Determine if the snapshot is the same as before"):
            with assume:
                assert uds_resp[7:] == snapshot_01
            iStep += 1

        Driver['CAN'].set_signal_Speed(0)
        # 生成故障
        Driver['CAN'].SetVolt(Driver, 7.5, 1.5, iStep)

        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04]+DTCNumber_V_L+[0x01], [0x59, 0x04]+DTCNumber_V_L+[0x09, 0x01], 0, iStep, False, 'UDS', 'noClearFault')
        snapshot_01 = uds_resp[7:]
        iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

        # 设置车速>3kph
        Driver['CAN'].set_signal_Speed(80)

        # 再次生成故障
        Driver['CAN'].SetVolt(Driver, 7.5, 1.5, iStep)
        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04]+DTCNumber_V_L+[0x01], [0x59, 0x04]+DTCNumber_V_L+[0x09, 0x01], 0, iStep, False, 'UDS', 'noClearFault')

        with allure.step(f"Step{iStep}: Determine if the snapshot is the same as before"):
            with assume:
                assert uds_resp[7:] == snapshot_01
        iStep += 1

        # 设置车速>3kph
        Driver['CAN'].set_signal_Speed(0)
        Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x14, 0xFF, 0xFF, 0xFF], [0x54], 0, iStep, False, 'UDS', 'noClearFault')

        return iStep

    @allure.severity('normal')
    @allure.title('Test abnormal voltage DTCSnapshot Record By DTCNumber in default session')
    @allure.description('Test abnormal voltage DTCSnapshot Record By DTCNumber in default session with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_DTCSnapshotRecordByDTCNumber_01_Default_Phy(self, action, Driver):
        DTCNumber = Set_up.DTC_list_all['DTC_VBAT_HIGH']
        iStep = 1
        Driver['CAN'].restartMRR_Power(Driver)
        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04] + DTCNumber+[0x01], [0x59, 0x04]+DTCNumber+[0x00], 1, iStep, False, 'UDS', 'ClearFault')
        self.SnapShot01(Driver, iStep)

    @allure.severity('normal')
    @allure.title('Test abnormal voltage DTCSnapshot Record By DTCNumber in default session')
    @allure.description('Test abnormal voltage DTCSnapshot Record By DTCNumber in extended session with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_DTCSnapshotRecordByDTCNumber_01_Extended_Phy(self, action, Driver):
        DTCNumber = Set_up.DTC_list_all['DTC_VBAT_HIGH']
        iStep = 1
        Driver['CAN'].restartMRR_Power(Driver)
        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04] + DTCNumber+[0x01], [0x59, 0x04]+DTCNumber+[0x00], 3, iStep, False, 'UDS', 'ClearFault')
        self.SnapShot01(Driver, iStep)

    def SnapShot02(self, Driver, iStep):
        DTCNumber_V_H = Set_up.DTC_list_all['DTC_VBAT_HIGH']
        DTCNumber_V_L = Set_up.DTC_list_all['DTC_VBAT_LOW']
        Other_DTC = Set_up.DTC_list_all['lost_communication_with_BCM']
        # 生成故障
        Driver['CAN'].SetVolt(Driver, 17.5, 1.5, iStep)
        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04]+DTCNumber_V_H+[0x01], [0x59, 0x04]+DTCNumber_V_H+[0x09, 0x01], 0, iStep, False, 'UDS', 'noClearFault')
        iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

        # 设置车速>3kph
        Driver['CAN'].set_signal_Speed(80)
        time.sleep(1.5)

        # 设置电压
        Driver['CAN'].SetVolt(Driver, 15, 1.5, iStep)
        # IGN status
        Driver['CAN'].set_signal_IGN(2)
        # 设置年
        Driver['CAN'].set_signal_Year(2022)  # 0x16
        # 设置月
        Driver['CAN'].set_signal_Month(9)  # 0x09
        # 设置日
        Driver['CAN'].set_signal_Day(16)   # 0x10
        # 设置时
        Driver['CAN'].set_signal_Hour(10)  # 0x0A
        # 设置分
        Driver['CAN'].set_signal_Minute(11)  # 0x0B
        # 设置秒
        Driver['CAN'].set_signal_Second(12)   # 0x0C
        Driver['CAN'].set_signal_Gear(2)
        time.sleep(2)

        # 生成故障
        Driver['CAN'].set_0x2F1_lost_error(True)
        time.sleep(1)

        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04]+Other_DTC+[0x01], [0x59, 0x04]+Other_DTC+[0x09, 0x01], 0, iStep, False, 'UDS', 'noClearFault')

        with allure.step(f"Step{iStep}: Determine whether the snapshot voltage data is 15v"):
            vltage = (uds_resp[22] << 8 | uds_resp[23])*0.01
            if 14.5 > vltage or vltage > 15.5:
                logging.error(f'correct vltage:[14.5 <= vltage <= 15.5], actual response:[{vltage}]')
            with assume:
                assert 14.5 <= vltage <= 15.5
            iStep += 1

        with allure.step(f"Step{iStep}: Determine whether the snapshot time data is 80"):
            if uds_resp[8:12] != [0x12, 0x61, 0x05, 0x8E]:
                actuRespStr = binascii.b2a_hex(bytearray(uds_resp[8:12]), ' ')
                logging.error(f'correct response:[0x12, 0x61, 0x05, 0x8E], actual response:[{actuRespStr}]')
            with assume:assert uds_resp[8:12] == [0x12, 0x61, 0x05, 0x8E]
            iStep += 1

        with allure.step(f"Step{iStep}: Determine whether the snapshot IGNstatus is 2"):
            if uds_resp[24:27] != [0x12, 0x62, 0x02]:
                actuRespStr = binascii.b2a_hex(bytearray(uds_resp[24:27]), ' ')
                logging.error(f'correct response:[0x12,0x62,0x02], actual response:[{actuRespStr}]')
            with assume:assert uds_resp[24:27] == [0x12, 0x62, 0x02]
            iStep += 1

        with allure.step(f"Step{iStep}: Determine whether the snapshot Gear is 2"):
            if uds_resp[27:30] != [0x12, 0x63, 0x02]:
                actuRespStr = binascii.b2a_hex(bytearray(uds_resp[27:30]), ' ')
                logging.error(f'correct response:[0x12,0x63,0x02], actual response:[{actuRespStr}]')
            with assume:
                assert uds_resp[27:30] == [0x12, 0x63, 0x02]
            iStep += 1

        with allure.step(f"Step{iStep}: Determine whether the SoC temperature is lower 200"):
            temperature = (uds_resp[32] << 8 | uds_resp[33])*0.01 - 40
            if temperature < -10 or temperature > 160:
                actuRespStr = binascii.b2a_hex(bytearray(uds_resp[30:34]), ' ')
                logging.error(f'correct response:[-10 < temperature < 160], actual response:[{actuRespStr}]')
            with assume:
                assert -10 < temperature < 160
            iStep += 1

        with allure.step(f"Step{iStep}: Determine whether the time data is 220916 10:11:12"):
            if uds_resp[12:20] != [0x12, 0x70, 0x22, 0x09, 0x16, 0x10, 0x11, 0x12]:
                actuRespStr = binascii.b2a_hex(bytearray(uds_resp[12:20]), ' ')
                logging.error(f'correct response:[0x12,0x70,0x22,0x09,0x16,0x10,0x11,0x12], actual response:[{actuRespStr}]')
            with assume:
                assert uds_resp[12:20] == [0x12, 0x70, 0x22, 0x09, 0x16, 0x10, 0x11, 0x12]
            iStep += 1

        # 恢复故障
        Driver['CAN'].set_0x2F1_lost_error(False)
        Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
        # 设置车速<3kph
        Driver['CAN'].set_signal_IGN(2)   # ACC 0x01
        # 设置车速
        Driver['CAN'].set_signal_Speed(0)  # 0x12
        # 设置年
        Driver['CAN'].set_signal_Year(2000)  # 0x16
        # 设置月
        Driver['CAN'].set_signal_Month(0)  # 0x09
        # 设置日
        Driver['CAN'].set_signal_Day(0)   # 0x10
        # 设置时
        Driver['CAN'].set_signal_Hour(0)  # 0x0A
        # 设置分
        Driver['CAN'].set_signal_Minute(0)  # 0x0B
        # 设置秒
        Driver['CAN'].set_signal_Second(0)   # 0x0C
        Driver['CAN'].set_signal_Gear(0)
        self.setSignalValue(Driver, St_EngineRunning, 0)
        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x14, 0xFF, 0xFF, 0xFF], [0x54], 0, iStep, False, 'UDS', 'noClearFault')

    @allure.severity('normal')
    @allure.title('Test abnormal voltage DTCSnapshot Record By DTCNumber in default session')
    @allure.description('Test abnormal voltage DTCSnapshot Record By DTCNumber in default session with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_DTCSnapshotRecordByDTCNumber_02_Default_Phy(self, action,  Driver):
        DTCNumber = Set_up.DTC_list_all['DTC_VBAT_HIGH']
        iStep = 1
        Driver['CAN'].restartMRR_Power(Driver)
        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04] + DTCNumber+[0x01], [0x59, 0x04]+DTCNumber+[0x00], 1, iStep, False, 'UDS', 'ClearFault')
        self.SnapShot02(Driver, iStep)

    @allure.severity('normal')
    @allure.title('Test abnormal voltage DTCSnapshot Record By DTCNumber in Extended session')
    @allure.description('Test abnormal voltage DTCSnapshot Record By DTCNumber in Extended session with physical addressing')
    @allure.testcase('https://chengtech.pingcode.com/testhub/libraries/630357052177ea2394680877/cases')
    def test_DTCSnapshotRecordByDTCNumber_02_Extended_Phy(self, action,  Driver):
        DTCNumber = Set_up.DTC_list_all['DTC_VBAT_HIGH']
        iStep = 1
        Driver['CAN'].restartMRR_Power(Driver)
        iStep, uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19, 0x04] + DTCNumber+[0x01], [0x59, 0x04]+DTCNumber+[0x00], 3, iStep, False, 'UDS', 'ClearFault')
        self.SnapShot02(Driver, iStep)
